<script>
	export default {
		globalData: {
			serverUrl: 'http://zhjx.zjhu.edu.cn',
			authUrl: 'https://rz.zjhu.edu.cn',
			userInfo: null,
			channelId: 'hzsf',
			// #ifdef H5
			appid: 'RPP0y74rvTxjKFLyLx',
			// #endif
			
			// #ifdef MP-WEIXIN
			appid: 'RPP0y74rvTxjKFLyLx',
			// #endif
			appSecret: 'c1147bbb205f41f5a74458a2488fa8c8',
			userPhone: '',//用户手机号
			token: '',
			orderNum:'' //扫码邀请的订单Id
		},
		onLaunch: function(options) {
			console.log(options)
			let _this = this;
			
			// #ifdef MP-WEIXIN
				if(options.query.scene && options.query.scene != undefined) {
					_this.globalData.orderNum = options.query.scene;
				}
			// #endif
				
			// #ifdef H5
				if (options.query.orderId && options.query.orderId != undefined) {
					let orderId = options.query.orderId;
					_this.globalData.orderNum = orderId;
					uni.setStorage({
						key: 'orderId',
						data: orderId
					});
				}else {
					uni.removeStorageSync('orderId');
				}
			// #endif	
			uni.getStorage({
				key: 'channelId',
			    success: function (res) {
			        _this.globalData.channelId = res.data;
			    }
			})
			
		},
		onShow: function() {
			//alert("app"+window.location.hash);
			/* console.log('App Show',this.globalData.token)
			if(this.globalData.token && this.globalData.orderNum && this.globalData.orderNum != '') {
				setTimeout(()=> {
					uni.navigateTo({
					    url: '/pages/classroom/classroom?orderId='+this.globalData.orderNum
					});
				},1500)
			} */
			let _this = this;
			uni.getStorage({
			    key: 'token',
			    success: function (res) {
			        _this.globalData.token = res.data;
					if(_this.globalData.token && _this.globalData.orderNum && _this.globalData.orderNum != '') {
						// setTimeout(()=> {
						// 	uni.navigateTo({
						// 	    url: '/pages/classroom/classroom?orderId='+_this.globalData.orderNum
						// 	});
						// },1500)
					}else if(window.location.hash.indexOf("signIn")!=-1){
						//如果要跳转到签到页面直接跳转
						uni.navigateTo({
						    url: window.location.hash
						});
					}else if(window.location.hash.indexOf("signOut")!=-1){
						//如果要跳转到签退页面直接跳转
						uni.navigateTo({
						    url: window.location.hash
						});
					}else if(window.location.hash.indexOf("h5Login")!=-1){
						//如果是从h5Login页面过来的则直接跳转过去再去拿新的token
						uni.navigateTo({
						    url: window.location.hash
						});
					}else if(window.location.hash.indexOf("onlineWarranty")!=-1){
					
					}else {
						uni.navigateTo({
						    url: '/pages/home/home'
						});
					}
			    }
			});
		},
		onHide: function() {
			// #ifdef H5
			uni.removeStorageSync('orderId');
			// uni.clearStorage();
			// #endif	
		},
	}
</script>

<style>
	uni-page-head{
		/* display: none; */
	}
	/*每个页面公共css */
	uni-radio .uni-radio-input.uni-radio-input-checked:before {
	    content: "";
	}
	@import "./wxcomponents/vant/dist/common/index.wxss";
</style>
